<?php

class ShippingAddress extends Zend_Db_Table_Abstract
{
    protected $_name = 'cms_shipping_address';
    protected $_primary = 'address_id';
    
    public function getShippingAddressById($id)
    {
        return $this->fetchRow($this->select()->where("address_id = ?", $id));
    }
	
	public function getShippingAddressByDealId($deal_id)
    {
        $query = "select d.email, d.name
                    from
                    	cms_order_item as a join 
                    	cms_order as b on a.order_id = b.order_id join 
                        cms_shipping_address as d on b.address_id = d.address_id
                    where a.deal_id = $deal_id AND b.status = 3";
        $tb = Zend_Db_Table::getDefaultAdapter();
        $tb->setFetchMode(Zend_Db::FETCH_OBJ);
        return $tb->fetchAll($query);
    }
}